package com.sayimo.maker.mall.orders.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sayimo.framework.database.mybatis.AbstractMybatisBaseDao;
import com.sayimo.framework.exception.DaoException;
import com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao;
import com.sayimo.maker.mall.orders.vo.OrdersReceivingAddress;



@Repository(value="ordersReceivingAddressInterfaceDao")
public class OrdersReceivingAddressInterfaceImplDao extends AbstractMybatisBaseDao<OrdersReceivingAddress> implements OrdersReceivingAddressInterfaceDao{

	@Override
	public void insertOrdersReceivingBatchCode(Map<String, Object> pm) throws DaoException {
		mybatisInterfaceBaseDao.insert("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.insertOrdersReceivingBatchCode", pm);
	}

	@Override
	public Integer queryOrdersReceivingCountByBatchCode(String batchCode) throws DaoException {
		return (Integer)mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.queryOrdersReceivingCountByBatchCode", batchCode);
	}
	
	/**
	 * 
	 * @MethodName queryOrdersReceivingAddressByBatchCode
	 * @Description 根据收货地址
	 * 
	 * @author chenpy
	 * @date 2016年1月8日 下午2:39:57
	 * @param 
	 * @return List<OrdersReceivingAddress>
	 * @VERSION 1.0.0
	 */
	public List<OrdersReceivingAddress> queryOrdersReceivingAddressByBatchCode(String batchCode) throws DaoException{
		return this.mybatisInterfaceBaseDao.query("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.queryOrdersReceivingAddressByBatchCode", batchCode);
		
	}

	@Override
	public OrdersReceivingAddress queryOrderReceivingCountByOrdersId(Integer ordersId) throws DaoException {
		return mybatisInterfaceBaseDao.get("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.queryOrderReceivingCountByOrdersId", ordersId);

	}

	@Override
	public Integer batchUpdateOrderRecevingAddr(List<OrdersReceivingAddress> list) throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.batchUpdateOrderRecevingAddr", list);
	}

	@Override
	public List<OrdersReceivingAddress> queryOrderReceivingCountByOrdersIds(List<Integer> ids) throws DaoException {
		return this.mybatisInterfaceBaseDao.query("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.queryOrderReceivingCountByOrdersIds", ids);
	}

	public void batchInsertOrdersRecevingAddr(List list) throws DaoException {
		this.mybatisInterfaceBaseDao.insert("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.batchInsertOrdersRecevingAddr", list);
	}

	/** 
	  * @package com.sayimo.school.mall.service.ope.impl
	  * @author chenpy
	  * @Title:  insertOrdersReceivingAddress
	  * @Description: 新增订单收货地址
	  * @param 
	  * @throws 
	  * @return int
	  * @date 2016年6月17日
	  */ 
	@Override
	public int insertOrdersReceivingAddress(Map<String, Object> paramAddress)
			throws DaoException {
		try {
			return this.mybatisInterfaceBaseDao.insert("com.sayimo.maker.mall.orders.dao.OrdersReceivingAddressInterfaceDao.insertOrdersReceivingAddress", paramAddress);
		} catch (DaoException e) {
//			logger.debug(e);
			throw new DaoException(e);
		}
	}

}
